package com.dime.basic.service.impl;

import java.util.List;

import com.dime.basic.mapper.DimeBasecombMapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dime.basic.mapper.DimeBasecombcriterionMapper;
import com.dime.basic.api.domain.DimeBasecombcriterion;
import com.dime.basic.service.IDimeBasecombcriterionService;

/**
 * 职业诊断标准必检项目Service业务层处理
 * 
 * @author Tiny
 * @date 2023-10-13
 */
@Service
public class DimeBasecombcriterionServiceImpl implements IDimeBasecombcriterionService 
{
    @Autowired
    private DimeBasecombcriterionMapper dimeBasecombcriterionMapper;

    @Autowired
    private DimeBasecombMapper dimeBasecombMapper;

    /**
     * 查询职业诊断标准必检项目
     * 
     * @param id 职业诊断标准必检项目主键
     * @return 职业诊断标准必检项目
     */
    @Override
    public DimeBasecombcriterion selectDimeBasecombcriterionById(String id)
    {
        return dimeBasecombcriterionMapper.selectDimeBasecombcriterionById(id);
    }

    /**
     * 查询职业诊断标准必检项目列表
     * 
     * @param dimeBasecombcriterion 职业诊断标准必检项目
     * @return 职业诊断标准必检项目
     */
    @Override
    public List<DimeBasecombcriterion> selectDimeBasecombcriterionList(DimeBasecombcriterion dimeBasecombcriterion)
    {
        return dimeBasecombcriterionMapper.selectDimeBasecombcriterionList(dimeBasecombcriterion);
    }

    /**
     * 新增职业诊断标准必检项目
     * 
     * @param dimeBasecombcriterion 职业诊断标准必检项目
     * @return 结果
     */
    @Override
    public int insertDimeBasecombcriterion(DimeBasecombcriterion dimeBasecombcriterion)
    {
        SetCombName(dimeBasecombcriterion);
        dimeBasecombcriterion.setId(IdUtils.fastUUID());
        dimeBasecombcriterion.setCreateBy(SecurityUtils.getUsername());
        dimeBasecombcriterion.setCreateTime(DateUtils.getNowDate());
        return dimeBasecombcriterionMapper.insertDimeBasecombcriterion(dimeBasecombcriterion);
    }

    private void SetCombName(DimeBasecombcriterion dimeBasecombcriterion) {
        String combName = dimeBasecombMapper.selectDimeBasecombById(dimeBasecombcriterion.getCombId()).getCombName();
        dimeBasecombcriterion.setCombName(combName);
    }

    /**
     * 修改职业诊断标准必检项目
     * 
     * @param dimeBasecombcriterion 职业诊断标准必检项目
     * @return 结果
     */
    @Override
    public int updateDimeBasecombcriterion(DimeBasecombcriterion dimeBasecombcriterion)
    {
        dimeBasecombcriterion.setUpdateBy(SecurityUtils.getUsername());
        dimeBasecombcriterion.setUpdateTime(DateUtils.getNowDate());
        return dimeBasecombcriterionMapper.updateDimeBasecombcriterion(dimeBasecombcriterion);
    }

    /**
     * 批量删除职业诊断标准必检项目
     * 
     * @param ids 需要删除的职业诊断标准必检项目主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecombcriterionByIds(String[] ids)
    {
        return dimeBasecombcriterionMapper.deleteDimeBasecombcriterionByIds(ids);
    }

    /**
     * 删除职业诊断标准必检项目信息
     * 
     * @param id 职业诊断标准必检项目主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecombcriterionById(String id)
    {
        return dimeBasecombcriterionMapper.deleteDimeBasecombcriterionById(id);
    }
}
